/**
 *  @auth: sce
 *  @date: 17-12-29
 *  @desc: 服务器请求工具
 **/
import config from './config'
import axios from 'axios'
import './../mock'

const {api} = config;
class Http{
    get(key,data){
        return this.ajax(key, data = null, 'get');
    }
    post(key, data){
        return this.ajax(key, data = null, 'post');
    }
    ajax(key, data, method){
        return axios({
            method,
            url: api[key],
            data
        }).then((result) => (result.data.data));
    }
}

export default new Http();